package componentes;

import com.example.primeiraaplicacao.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.Toast;

public class ExemploSubMenu extends Activity {
	public void onCreate (Bundle icicle){
		super.onCreate (icicle);
		setContentView(R.layout.main);
	}
	
	public boolean onCreateOptionsMenu(Menu menu){
		super.onCreateOptionsMenu(menu);
		MenuItem item=menu.add(0,0,0,"Novo");
		item=menu.add(0,1,0,"Salvar");
		item=menu.add(0,2,0,"Excluir");
		
		SubMenu subMenu=menu.addSubMenu(0,3,0, "Outros");
		item=subMenu.add(0,4,0,"Pesquisar");
		item=subMenu.add(0,5,0,"Limpar");
		item=subMenu.add(0,6,0,"Sair");
		
		return true;
	}
	
	public boolean onMenuItemSelected(int featuredId,MenuItem item){
		switch(item.getItemId()){
		case 0:
			Toast.makeText(ExemploSubMenu.this, "Novo!", Toast.LENGTH_SHORT).show();
			break;
		case 6:
			Toast.makeText(ExemploSubMenu.this, "Sair!", Toast.LENGTH_SHORT).show();
			break;
		}
		return false;
	}

}
